<template>
  <div>
      <h2>会员列表</h2>
      <table class="table table-bordered">
        <tr>
          <td>ID</td>
          <td>会员名称</td>
          <td>操作</td>
        </tr>
        <tr v-for="item in list">
          <td>{{ item.mId }}</td>
          <td>{{ item.mName }}</td>
          <td>
            <input type="button" value="送优惠券" @click="send(item.mId)">
            <input type="button" value="修改">
            <input type="button" value="注销">
            <input type="button" value="删除">
          </td>
        </tr>
      </table>
  </div>
</template>

<script setup lang="ts">
import {reactive,toRefs,onMounted}  from 'vue'
import  axios from 'axios'
import { useRouter,useRoute} from 'vue-router'
import { useUserStore} from '../stores/user'


const route = useRoute();
const router = useRouter();
const userStore = useUserStore()


let data:any = reactive({
  list:[]
})

let {list} = toRefs(data)

onMounted(()=>{
  getMemberList()
})

//送优惠券
const send = (id:any)=>{
  router.push({
    path:'/validDiscount',
    query:{
      id:id
    }
  })
}


//获取会员列表
const getMemberList = ()=>{
  axios({
    url:'/api/Test/GetMemberList',
    method:'get'
  })
  .then(res=>{
    console.log(res);
    list.value = res.data.data
    
  })
  .catch(err=>{
    console.log(err);
    
  })
}
</script>

<style scoped>

</style>